﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
using System.IO;

namespace HelloAsp
{
    public partial class _Default : System.Web.UI.Page
    {
        string result = String.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            result += "Page Load fired <br />";
        }

        protected void Page_PreInit(object sender, EventArgs e)
        {
            result += "Page PreInit fired <br />";
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            result += "Page Init fired <br />";
        }

        protected void Page_InitComplete(object sender, EventArgs e)
        {
            result += "Page InitComplete fired <br />";
        }

        protected void Page_PreLoad(object sender, EventArgs e)
        {
            result += "Page PreLoad fired <br />";
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            result += "Page PreRender fired <br />";
        }

        protected void Page_PreRenderComplete(object sender, EventArgs e)
        {
            result += "Page PreRenderComplete fired <br />";
        }

        protected void Page_SaveStateComplete(object sender, EventArgs e)
        {
            result += "Page SaveStateComplete fired <br />";
            Response.Write(result);
        }

        protected void ButtonShowGreeting_Click(object sender, EventArgs e)
        {
            if (LabelGreeting.Text == "")
            {
                LabelGreeting.Text = "Hell ASP.NET";
            }
            else
            {
                LabelGreeting.Text = "";
            }
        }

        protected void ButtonShowFiles_Click(object sender, EventArgs e)
        {
            FileInfo file = new FileInfo(Assembly.GetExecutingAssembly().Location);
            DirectoryInfo dir = new DirectoryInfo(file.Directory.ToString());
            foreach (FileInfo item in dir.GetFiles())
            {
                Response.Write(item);
            }
        }

        protected void ButtonCreateFile_Click(object sender, EventArgs e)
        {
            FileStream file = File.Create(@"C:\Program files\New file.txt");
            file.Close();
        }
    }
}
